package com.mdd.admin.controller;

import com.mdd.common.aop.NotLogin;
import com.mdd.admin.service.IIndexService;
import com.mdd.common.core.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("api/index")
@Api(tags = "主页数据管理")
public class IndexController {

    @Resource
    IIndexService iIndexService;

    @GetMapping("/console")
    @ApiOperation(value="控制台")
    public AjaxResult<Map<String, Object>> console(@RequestParam(required = false) Map<String, Integer> params) {
        Long startTime = params.get("startTime") == null ? null : Long.parseLong(String.valueOf(params.get("startTime")));
        Long endTime = params.get("endTime") == null ? null : Long.parseLong(String.valueOf(params.get("endTime")));
        Map<String, Object> map = iIndexService.console(startTime,endTime);
        return AjaxResult.success(map);
    }

    @NotLogin
    @GetMapping("/config")
    @ApiOperation(value="公共配置")
    public AjaxResult<Map<String, Object>> config() {
        Map<String, Object> map = iIndexService.config();
        return AjaxResult.success(map);
    }

    @NotLogin
    @GetMapping("/check")
    @ApiOperation(value="正版检测")
    public AjaxResult<Object> checkAuth() {
        Map<String, Object> result = iIndexService.checkAuth();
        return AjaxResult.success(result);
    }

}
